package com.web.server.common.utils;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by QINZHONGCHENG on 2015/10/26.
 */

public class Constant {
    public static final Integer BATCH_INSERT_SIZE = 500; //批量插入数量

    public static final Float couponValue = 0.00F;
    public static final Boolean useDebugCouponValue = false;

    public static final String CHARSET_UTF = "UTF-8";
    public static final String CHARSET_GBK = "GBK";
    public static final String CHARSET_GB2312 = "GB2312";
    public static final String CHARSET_GB18030 = "GB18030";
    public static final String CHARSET_UNICODE = "UNICODE";
    public static final String CHARSET_ISO88591 = "ISO-8859-1";
    public static final String[] CHARSET_ARRAY = new String[]{CHARSET_UTF, CHARSET_GBK, CHARSET_GB2312};
    public static final String COLON = ":";
    public static final String REDIS_CACHE_KEY_LOGGED_USER = "loggedUserCacheKey";  // 登录用户信息放置在Redis上的Key
    /**
     * 字符串空�?
     */
    public static final String BLANK = " ";
    /***
     * 英文句点
     */
    public static final String ENGLISH_PERIOD = ".";
    /***
     * 英文省略�?
     */
    public static final String ENGLISH_ELLIPSIS = "...";
    /***
     * "0"
     */
    public static final String ZERO_STRING = "0";
    /***
     * -1
     */
    public static final int NEGATIVE_ONE = -1;
    /***
     * 空字符串:""
     */
    public static final String EMPTY = "";

    //errorCode
    public static Map<String, String> msgMap = new HashMap<String, String>();

    static {
        msgMap.put("0", "网络无法连接，请检查网络连接状况。");
        msgMap.put("2", "抱歉，网络连接超时，请退出重试。");
        msgMap.put("202", "抱歉，该页面暂无法响应;请退出重试（902）");
        msgMap.put("400", "服务器不理解请求的语法");
        msgMap.put("401", "亲，请重新登录");
        msgMap.put("403", "亲，请重新登录");
        msgMap.put("404", "抱歉，服务器找不到请求的网页（404）");
        msgMap.put("405", "网络不给力，请稍后再试（405）");
        msgMap.put("406", "网络不给力，请稍后再试（406）");
        msgMap.put("407", "网络不给力，请稍后再试（407）");
        msgMap.put("408", "服务器等候请求时发生超时");
        msgMap.put("409", "服务器在完成请求时发生冲突");
        msgMap.put("410", "网络不给力，请稍后再试（410）");
        msgMap.put("500", "抱歉，服务器遇到错误，无法完成请求（500）");
        msgMap.put("503", "抱歉，该页面暂无法响应，请退出重试或点击其他页面！");
        msgMap.put("20024_LOGIN", "抱歉，您的登录错误次数超过限制，请15分钟后再登录");
        // 自定义错误码

        msgMap.put("20026", "内容含有敏感词");
        msgMap.put("20001", "敏感词服务异常");
    }

    public static String getErrorMsg(String code) {
        String msg = Constant.msgMap.get(code);
        if (msg == null) {
            msg = "未知错误(" + code + ")";
        }
        return msg;
    }

}
